<%@ page pageEncoding="UTF-8"%>
<html>
<head>
	<title>用户管理</title>
</head>
<body>
	<h3>用户管理</h3>
<div style = "background: url(../images/menuBg.png) repeat fixed; height:420px">
	<form id="form">
		<div class="content_head">
			<label>姓名</label><input id="queryName" type="text"/>
			<a href="javascript:void(0)" id="querySubmit" onclick="selectUser();" class="commonbtn">查询</a>
			<a href="javascript:void(0)" onclick="openUrl('/user/addUserView.do');" class="commonbtn">新增</a>
			<a href="javascript:void(0)" onclick="reset();" class="commonbtn">重置查询条件</a>
		</div>
		<table id="datagrid"></table>
	</form>
</div>
<script type="text/javascript">
$(function(){
	$('#datagrid').datagrid({
	    url:'/user/listUser.do',
	    rownumbers:true,
	    height:330,
	    columns:[[
            {field:'id',title:'操作',width:80,align:'center',formatter: function(value,row,index){
  				return "<a href='javascript:void(0)' onclick=\"openUrl('/user/updateUserView.do?id=" + value + "');\">编辑</a>";
  			}},
	        {field:'username',title:'用户名',width:100},
	        {field:'name',title:'姓名',width:100},
	        {field:'deptId',title:'部门',width:100,formatter: function(value,row,index){
				if (row.dept){
					return row.dept.name;
				} else {
					return value;
				}
			}},
	        {field:'roleId',title:'角色',width:100,formatter: function(value,row,index){
				if (row.sysrole){
					return row.sysrole.name;
				} else {
					return value;
				}
			}},
	        {field:'telephone',title:'电话',width:100},
	        {field:'email',title:'邮箱',width:130}
	    ]],
	    pagination:true
	});
	$('#datagrid').datagrid('getPager').pagination({
		pagePosition:'bottom',
	    pageNumber:1,
	    pageSize:10,
	    pageList:[10,20]
	});
	//设置回车提交
	enterSubmit('querySubmit');
});

function selectUser(){
	var name = $("#queryName").val();
	$('#datagrid').datagrid('load', {
		name: name
	});
}

//查询条件清空
function reset(){
	$('#queryName').val("");
}
</script>
</body>
</html>
